<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>设备审批记录</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function batchProcesst(flag){
			var groupList = "";
            $("#contentTable").find("input[type='checkbox']").each(function(){
                if ($(this).prop('checked')) {
                    var egId = $(this).attr("id");
                    groupList = groupList + "'"+egId + "',";
                }
            });
            $.ajax({
                type: "POST",
                url: "${ctx}/equipment/eleEquipment/checkEquipment",
                data: {groupList: groupList, flag: flag},
                datatype: "json",
                success: function (data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function () {
                    //请求出错处理
                }
            });
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/equipment/eleEquipment/mychecklist?flag=true">设备审批记录</a></li>
	</ul>
	<div class="control-group" style="margin-bottom:20px;background-color:#f5f5f5;" >
		<input type="button" value="批量通过" class="btn btn-default btn-lg" onclick="batchProcesst('pass');">
		<input type="button" value="批量驳回" class="btn btn-default btn-lg" onclick="batchProcesst('reject');">
		<input type="button" value="批量删除" class="btn btn-default btn-lg" onclick="batchProcesst('delete');">
	<form:form id="searchForm" modelAttribute="eleEquipment" action="${ctx}/equipment/eleEquipment/mychecklist"
			   method="post" class="breadcrumb form-search" style="float:right;padding-bottom:0px;padding-top:0px;">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
        <input name="flag" type="hidden" value="${flag}">
        <input name="isFirst" type="hidden" value="${isFirst}">
		<ul class="ul-form">
            <li><label><spring:message code="common.device.id"/>：</label>
                <form:input path="code" htmlEscape="false" maxlength="200" class="input-medium"/>
            </li>
			<li><label><spring:message code='common.status'/>：</label>
                <form:select path="delFlag" htmlEscape="false"  class="input-medium">
                    <form:option value="5">所有</form:option>
                    <form:option value="0"><spring:message code="common.approved"/></form:option>
                    <form:option value="1"><spring:message code='common.delete'/></form:option>
                    <form:option value="2">审核中</form:option>
                    <form:option value="3"><spring:message code="common.reject"/></form:option>
                </form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="<spring:message code='common.Query'/>"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	</div>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><spring:message code="common.device.id"/></th>
                <th><spring:message code='common.remarks'/></th>
                <th><spring:message code="common.group.group"/></th>
                <th>${flag?"<spring:message code='common.applicant'/>":"<spring:message code='common.approver'/>"}</th>
				<th>申请时间</th>
                <th>审批状态</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="eleEquipment">
			<tr>
				<td><a href="${ctx}/equipment/eleEquipment/info?id=${eleEquipment.id}&showtype=2">
					${eleEquipment.code}
				</a></td>
				<td> ${eleEquipment.remarks} </td>
                <td> ${eleEquipment.office.name} </td>
				<td>${flag?eleEquipment.createBy.name:eleEquipment.checkBy.name} </td>
				<td><fmt:formatDate value="${eleEquipment.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
				<td>
                    <c:if test="${eleEquipment.delFlag == '0'}">
                        <spring:message code="common.approved"/>
                    </c:if>
                    <c:if test="${eleEquipment.delFlag == '1'}">
                        <spring:message code='common.delete'/>
                    </c:if>
                    <c:if test="${eleEquipment.delFlag == '2'}">
                        审核中
                    </c:if>
                    <c:if test="${eleEquipment.delFlag == '3'}">
                        <spring:message code="common.reject"/>
                    </c:if>
                </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>